import {BadRequestException, PipeTransform} from '@nestjs/common';

export class ParseFloatPipe implements PipeTransform<string, number> {
    transform(value: string, metadata): number {
        const val = parseFloat(value);
        if (isNaN(val)) {
            throw new BadRequestException(`myCore: Validation failed (float string is expected)`);
        }
        return val
    }
}
